import functools
import aioredis
from aioredis import Redis

from src.config.conf import cfg

pool = aioredis.ConnectionPool.from_url(
    f"redis://{cfg.redis.host}",
    port=cfg.redis.port,
    password=cfg.redis.password,
    db=cfg.redis.db,
    encoding=cfg.redis.encoding,
    decode_responses=cfg.redis.decode_responses,
    max_connections=10
)
redis = aioredis.Redis(connection_pool=pool)

def get_redis() -> Redis:
    return redis
